package com.netintech.intelligenceInterface.iflytek.util;

import com.netintech.intelligenceInterface.common.StaticBean;
import org.springframework.http.MediaType;
import org.springframework.http.HttpHeaders;

import java.util.Collections;
import java.util.Map;

/**
 * @author lining
 * @date 2021/5/18 13:52
 */
public class HeadersUtil {
    public static HttpHeaders getHeader(String url) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
        Map<String, String> authHeader = AuthUtils.assembleRequestHeader("POST", url, StaticBean.API_KEY, StaticBean.API_SECRET, null);
        authHeader.forEach(headers::add);
        return headers;
    }

    public static HttpHeaders getMultiHeader(String url) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
        Map<String, String> authHeader = AuthUtils.assembleRequestHeader("POST", url, StaticBean.API_KEY, StaticBean.API_SECRET, null);
        authHeader.forEach(headers::add);
        return headers;
    }
}
